<?php


/**
 * Base class that represents a query for the 'event_requests' table.
 *
 *
 *
 * @method RcpEventRequestsQuery orderById($order = Criteria::ASC) Order by the id column
 * @method RcpEventRequestsQuery orderByEventRequestTypeId($order = Criteria::ASC) Order by the event_request_type_id column
 * @method RcpEventRequestsQuery orderByStatus($order = Criteria::ASC) Order by the status column
 * @method RcpEventRequestsQuery orderByCorporateOutput($order = Criteria::ASC) Order by the corporate_output column
 * @method RcpEventRequestsQuery orderByWorkOffDate($order = Criteria::ASC) Order by the work_off_date column
 * @method RcpEventRequestsQuery orderByComment($order = Criteria::ASC) Order by the comment column
 * @method RcpEventRequestsQuery orderByRecompenseType($order = Criteria::ASC) Order by the recompense_type column
 * @method RcpEventRequestsQuery orderByLastModified($order = Criteria::ASC) Order by the last_modified column
 * @method RcpEventRequestsQuery orderByCreated($order = Criteria::ASC) Order by the created column
 *
 * @method RcpEventRequestsQuery groupById() Group by the id column
 * @method RcpEventRequestsQuery groupByEventRequestTypeId() Group by the event_request_type_id column
 * @method RcpEventRequestsQuery groupByStatus() Group by the status column
 * @method RcpEventRequestsQuery groupByCorporateOutput() Group by the corporate_output column
 * @method RcpEventRequestsQuery groupByWorkOffDate() Group by the work_off_date column
 * @method RcpEventRequestsQuery groupByComment() Group by the comment column
 * @method RcpEventRequestsQuery groupByRecompenseType() Group by the recompense_type column
 * @method RcpEventRequestsQuery groupByLastModified() Group by the last_modified column
 * @method RcpEventRequestsQuery groupByCreated() Group by the created column
 *
 * @method RcpEventRequestsQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method RcpEventRequestsQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method RcpEventRequestsQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method RcpEventRequestsQuery leftJoinEventRequestTypes($relationAlias = null) Adds a LEFT JOIN clause to the query using the EventRequestTypes relation
 * @method RcpEventRequestsQuery rightJoinEventRequestTypes($relationAlias = null) Adds a RIGHT JOIN clause to the query using the EventRequestTypes relation
 * @method RcpEventRequestsQuery innerJoinEventRequestTypes($relationAlias = null) Adds a INNER JOIN clause to the query using the EventRequestTypes relation
 *
 * @method RcpEventRequestsQuery leftJoinEventRequestComments($relationAlias = null) Adds a LEFT JOIN clause to the query using the EventRequestComments relation
 * @method RcpEventRequestsQuery rightJoinEventRequestComments($relationAlias = null) Adds a RIGHT JOIN clause to the query using the EventRequestComments relation
 * @method RcpEventRequestsQuery innerJoinEventRequestComments($relationAlias = null) Adds a INNER JOIN clause to the query using the EventRequestComments relation
 *
 * @method RcpEventRequestsQuery leftJoinEventRequestHasCalendarEvent($relationAlias = null) Adds a LEFT JOIN clause to the query using the EventRequestHasCalendarEvent relation
 * @method RcpEventRequestsQuery rightJoinEventRequestHasCalendarEvent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the EventRequestHasCalendarEvent relation
 * @method RcpEventRequestsQuery innerJoinEventRequestHasCalendarEvent($relationAlias = null) Adds a INNER JOIN clause to the query using the EventRequestHasCalendarEvent relation
 *
 * @method RcpEventRequestsQuery leftJoinEventRequestProposalFreeDay($relationAlias = null) Adds a LEFT JOIN clause to the query using the EventRequestProposalFreeDay relation
 * @method RcpEventRequestsQuery rightJoinEventRequestProposalFreeDay($relationAlias = null) Adds a RIGHT JOIN clause to the query using the EventRequestProposalFreeDay relation
 * @method RcpEventRequestsQuery innerJoinEventRequestProposalFreeDay($relationAlias = null) Adds a INNER JOIN clause to the query using the EventRequestProposalFreeDay relation
 *
 * @method RcpEventRequestsQuery leftJoinViewCalendarEvents($relationAlias = null) Adds a LEFT JOIN clause to the query using the ViewCalendarEvents relation
 * @method RcpEventRequestsQuery rightJoinViewCalendarEvents($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ViewCalendarEvents relation
 * @method RcpEventRequestsQuery innerJoinViewCalendarEvents($relationAlias = null) Adds a INNER JOIN clause to the query using the ViewCalendarEvents relation
 *
 * @method RcpEventRequests findOne(PropelPDO $con = null) Return the first RcpEventRequests matching the query
 * @method RcpEventRequests findOneOrCreate(PropelPDO $con = null) Return the first RcpEventRequests matching the query, or a new RcpEventRequests object populated from the query conditions when no match is found
 *
 * @method RcpEventRequests findOneById(int $id) Return the first RcpEventRequests filtered by the id column
 * @method RcpEventRequests findOneByEventRequestTypeId(int $event_request_type_id) Return the first RcpEventRequests filtered by the event_request_type_id column
 * @method RcpEventRequests findOneByStatus(int $status) Return the first RcpEventRequests filtered by the status column
 * @method RcpEventRequests findOneByCorporateOutput(boolean $corporate_output) Return the first RcpEventRequests filtered by the corporate_output column
 * @method RcpEventRequests findOneByWorkOffDate(string $work_off_date) Return the first RcpEventRequests filtered by the work_off_date column
 * @method RcpEventRequests findOneByComment(string $comment) Return the first RcpEventRequests filtered by the comment column
 * @method RcpEventRequests findOneByRecompenseType(int $recompense_type) Return the first RcpEventRequests filtered by the recompense_type column
 * @method RcpEventRequests findOneByLastModified(string $last_modified) Return the first RcpEventRequests filtered by the last_modified column
 * @method RcpEventRequests findOneByCreated(string $created) Return the first RcpEventRequests filtered by the created column
 *
 * @method array findById(int $id) Return RcpEventRequests objects filtered by the id column
 * @method array findByEventRequestTypeId(int $event_request_type_id) Return RcpEventRequests objects filtered by the event_request_type_id column
 * @method array findByStatus(int $status) Return RcpEventRequests objects filtered by the status column
 * @method array findByCorporateOutput(boolean $corporate_output) Return RcpEventRequests objects filtered by the corporate_output column
 * @method array findByWorkOffDate(string $work_off_date) Return RcpEventRequests objects filtered by the work_off_date column
 * @method array findByComment(string $comment) Return RcpEventRequests objects filtered by the comment column
 * @method array findByRecompenseType(int $recompense_type) Return RcpEventRequests objects filtered by the recompense_type column
 * @method array findByLastModified(string $last_modified) Return RcpEventRequests objects filtered by the last_modified column
 * @method array findByCreated(string $created) Return RcpEventRequests objects filtered by the created column
 *
 * @package    propel.generator.rcp.om
 */
abstract class RcpBaseEventRequestsQuery extends ModelCriteria
{
    /**
     * Initializes internal state of RcpBaseEventRequestsQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vgp_rcp', $modelName = 'RcpEventRequests', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new RcpEventRequestsQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     RcpEventRequestsQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return RcpEventRequestsQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof RcpEventRequestsQuery) {
            return $criteria;
        }
        $query = new RcpEventRequestsQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   RcpEventRequests|RcpEventRequests[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = RcpEventRequestsPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(RcpEventRequestsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   RcpEventRequests A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT ID, EVENT_REQUEST_TYPE_ID, STATUS, CORPORATE_OUTPUT, WORK_OFF_DATE, COMMENT, RECOMPENSE_TYPE, LAST_MODIFIED, CREATED FROM event_requests WHERE ID = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new RcpEventRequests();
            $obj->hydrate($row);
            RcpEventRequestsPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return RcpEventRequests|RcpEventRequests[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|RcpEventRequests[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(RcpEventRequestsPeer::ID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(RcpEventRequestsPeer::ID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the id column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE id = 1234
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE id > 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(RcpEventRequestsPeer::ID, $id, $comparison);
    }

    /**
     * Filter the query on the event_request_type_id column
     *
     * Example usage:
     * <code>
     * $query->filterByEventRequestTypeId(1234); // WHERE event_request_type_id = 1234
     * $query->filterByEventRequestTypeId(array(12, 34)); // WHERE event_request_type_id IN (12, 34)
     * $query->filterByEventRequestTypeId(array('min' => 12)); // WHERE event_request_type_id > 12
     * </code>
     *
     * @see       filterByEventRequestTypes()
     *
     * @param     mixed $eventRequestTypeId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function filterByEventRequestTypeId($eventRequestTypeId = null, $comparison = null)
    {
        if (is_array($eventRequestTypeId)) {
            $useMinMax = false;
            if (isset($eventRequestTypeId['min'])) {
                $this->addUsingAlias(RcpEventRequestsPeer::EVENT_REQUEST_TYPE_ID, $eventRequestTypeId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($eventRequestTypeId['max'])) {
                $this->addUsingAlias(RcpEventRequestsPeer::EVENT_REQUEST_TYPE_ID, $eventRequestTypeId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpEventRequestsPeer::EVENT_REQUEST_TYPE_ID, $eventRequestTypeId, $comparison);
    }

    /**
     * Filter the query on the status column
     *
     * Example usage:
     * <code>
     * $query->filterByStatus(1234); // WHERE status = 1234
     * $query->filterByStatus(array(12, 34)); // WHERE status IN (12, 34)
     * $query->filterByStatus(array('min' => 12)); // WHERE status > 12
     * </code>
     *
     * @param     mixed $status The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function filterByStatus($status = null, $comparison = null)
    {
        if (is_array($status)) {
            $useMinMax = false;
            if (isset($status['min'])) {
                $this->addUsingAlias(RcpEventRequestsPeer::STATUS, $status['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($status['max'])) {
                $this->addUsingAlias(RcpEventRequestsPeer::STATUS, $status['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpEventRequestsPeer::STATUS, $status, $comparison);
    }

    /**
     * Filter the query on the corporate_output column
     *
     * Example usage:
     * <code>
     * $query->filterByCorporateOutput(true); // WHERE corporate_output = true
     * $query->filterByCorporateOutput('yes'); // WHERE corporate_output = true
     * </code>
     *
     * @param     boolean|string $corporateOutput The value to use as filter.
     *              Non-boolean arguments are converted using the following rules:
     *                * 1, '1', 'true',  'on',  and 'yes' are converted to boolean true
     *                * 0, '0', 'false', 'off', and 'no'  are converted to boolean false
     *              Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function filterByCorporateOutput($corporateOutput = null, $comparison = null)
    {
        if (is_string($corporateOutput)) {
            $corporate_output = in_array(strtolower($corporateOutput), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
        }

        return $this->addUsingAlias(RcpEventRequestsPeer::CORPORATE_OUTPUT, $corporateOutput, $comparison);
    }

    /**
     * Filter the query on the work_off_date column
     *
     * Example usage:
     * <code>
     * $query->filterByWorkOffDate('fooValue');   // WHERE work_off_date = 'fooValue'
     * $query->filterByWorkOffDate('%fooValue%'); // WHERE work_off_date LIKE '%fooValue%'
     * </code>
     *
     * @param     string $workOffDate The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function filterByWorkOffDate($workOffDate = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($workOffDate)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $workOffDate)) {
                $workOffDate = str_replace('*', '%', $workOffDate);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(RcpEventRequestsPeer::WORK_OFF_DATE, $workOffDate, $comparison);
    }

    /**
     * Filter the query on the comment column
     *
     * Example usage:
     * <code>
     * $query->filterByComment('fooValue');   // WHERE comment = 'fooValue'
     * $query->filterByComment('%fooValue%'); // WHERE comment LIKE '%fooValue%'
     * </code>
     *
     * @param     string $comment The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function filterByComment($comment = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($comment)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $comment)) {
                $comment = str_replace('*', '%', $comment);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(RcpEventRequestsPeer::COMMENT, $comment, $comparison);
    }

    /**
     * Filter the query on the recompense_type column
     *
     * Example usage:
     * <code>
     * $query->filterByRecompenseType(1234); // WHERE recompense_type = 1234
     * $query->filterByRecompenseType(array(12, 34)); // WHERE recompense_type IN (12, 34)
     * $query->filterByRecompenseType(array('min' => 12)); // WHERE recompense_type > 12
     * </code>
     *
     * @param     mixed $recompenseType The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function filterByRecompenseType($recompenseType = null, $comparison = null)
    {
        if (is_array($recompenseType)) {
            $useMinMax = false;
            if (isset($recompenseType['min'])) {
                $this->addUsingAlias(RcpEventRequestsPeer::RECOMPENSE_TYPE, $recompenseType['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($recompenseType['max'])) {
                $this->addUsingAlias(RcpEventRequestsPeer::RECOMPENSE_TYPE, $recompenseType['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpEventRequestsPeer::RECOMPENSE_TYPE, $recompenseType, $comparison);
    }

    /**
     * Filter the query on the last_modified column
     *
     * Example usage:
     * <code>
     * $query->filterByLastModified('2011-03-14'); // WHERE last_modified = '2011-03-14'
     * $query->filterByLastModified('now'); // WHERE last_modified = '2011-03-14'
     * $query->filterByLastModified(array('max' => 'yesterday')); // WHERE last_modified > '2011-03-13'
     * </code>
     *
     * @param     mixed $lastModified The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function filterByLastModified($lastModified = null, $comparison = null)
    {
        if (is_array($lastModified)) {
            $useMinMax = false;
            if (isset($lastModified['min'])) {
                $this->addUsingAlias(RcpEventRequestsPeer::LAST_MODIFIED, $lastModified['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($lastModified['max'])) {
                $this->addUsingAlias(RcpEventRequestsPeer::LAST_MODIFIED, $lastModified['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpEventRequestsPeer::LAST_MODIFIED, $lastModified, $comparison);
    }

    /**
     * Filter the query on the created column
     *
     * Example usage:
     * <code>
     * $query->filterByCreated('2011-03-14'); // WHERE created = '2011-03-14'
     * $query->filterByCreated('now'); // WHERE created = '2011-03-14'
     * $query->filterByCreated(array('max' => 'yesterday')); // WHERE created > '2011-03-13'
     * </code>
     *
     * @param     mixed $created The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function filterByCreated($created = null, $comparison = null)
    {
        if (is_array($created)) {
            $useMinMax = false;
            if (isset($created['min'])) {
                $this->addUsingAlias(RcpEventRequestsPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($created['max'])) {
                $this->addUsingAlias(RcpEventRequestsPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpEventRequestsPeer::CREATED, $created, $comparison);
    }

    /**
     * Filter the query by a related RcpEventRequestTypes object
     *
     * @param   RcpEventRequestTypes|PropelObjectCollection $eventRequestTypes The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   RcpEventRequestsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByEventRequestTypes($eventRequestTypes, $comparison = null)
    {
        if ($eventRequestTypes instanceof RcpEventRequestTypes) {
            return $this
                ->addUsingAlias(RcpEventRequestsPeer::EVENT_REQUEST_TYPE_ID, $eventRequestTypes->getId(), $comparison);
        } elseif ($eventRequestTypes instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(RcpEventRequestsPeer::EVENT_REQUEST_TYPE_ID, $eventRequestTypes->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByEventRequestTypes() only accepts arguments of type RcpEventRequestTypes or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the EventRequestTypes relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function joinEventRequestTypes($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('EventRequestTypes');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'EventRequestTypes');
        }

        return $this;
    }

    /**
     * Use the EventRequestTypes relation EventRequestTypes object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   RcpEventRequestTypesQuery A secondary query class using the current class as primary query
     */
    public function useEventRequestTypesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinEventRequestTypes($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'EventRequestTypes', 'RcpEventRequestTypesQuery');
    }

    /**
     * Filter the query by a related RcpEventRequestComments object
     *
     * @param   RcpEventRequestComments|PropelObjectCollection $eventRequestComments  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   RcpEventRequestsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByEventRequestComments($eventRequestComments, $comparison = null)
    {
        if ($eventRequestComments instanceof RcpEventRequestComments) {
            return $this
                ->addUsingAlias(RcpEventRequestsPeer::ID, $eventRequestComments->getEventRequestId(), $comparison);
        } elseif ($eventRequestComments instanceof PropelObjectCollection) {
            return $this
                ->useEventRequestCommentsQuery()
                ->filterByPrimaryKeys($eventRequestComments->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByEventRequestComments() only accepts arguments of type RcpEventRequestComments or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the EventRequestComments relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function joinEventRequestComments($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('EventRequestComments');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'EventRequestComments');
        }

        return $this;
    }

    /**
     * Use the EventRequestComments relation EventRequestComments object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   RcpEventRequestCommentsQuery A secondary query class using the current class as primary query
     */
    public function useEventRequestCommentsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinEventRequestComments($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'EventRequestComments', 'RcpEventRequestCommentsQuery');
    }

    /**
     * Filter the query by a related RcpEventRequestHasCalendarEvent object
     *
     * @param   RcpEventRequestHasCalendarEvent|PropelObjectCollection $eventRequestHasCalendarEvent  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   RcpEventRequestsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByEventRequestHasCalendarEvent($eventRequestHasCalendarEvent, $comparison = null)
    {
        if ($eventRequestHasCalendarEvent instanceof RcpEventRequestHasCalendarEvent) {
            return $this
                ->addUsingAlias(RcpEventRequestsPeer::ID, $eventRequestHasCalendarEvent->getEventRequestId(), $comparison);
        } elseif ($eventRequestHasCalendarEvent instanceof PropelObjectCollection) {
            return $this
                ->useEventRequestHasCalendarEventQuery()
                ->filterByPrimaryKeys($eventRequestHasCalendarEvent->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByEventRequestHasCalendarEvent() only accepts arguments of type RcpEventRequestHasCalendarEvent or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the EventRequestHasCalendarEvent relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function joinEventRequestHasCalendarEvent($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('EventRequestHasCalendarEvent');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'EventRequestHasCalendarEvent');
        }

        return $this;
    }

    /**
     * Use the EventRequestHasCalendarEvent relation EventRequestHasCalendarEvent object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   RcpEventRequestHasCalendarEventQuery A secondary query class using the current class as primary query
     */
    public function useEventRequestHasCalendarEventQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinEventRequestHasCalendarEvent($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'EventRequestHasCalendarEvent', 'RcpEventRequestHasCalendarEventQuery');
    }

    /**
     * Filter the query by a related RcpEventRequestProposalFreeDay object
     *
     * @param   RcpEventRequestProposalFreeDay|PropelObjectCollection $eventRequestProposalFreeDay  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   RcpEventRequestsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByEventRequestProposalFreeDay($eventRequestProposalFreeDay, $comparison = null)
    {
        if ($eventRequestProposalFreeDay instanceof RcpEventRequestProposalFreeDay) {
            return $this
                ->addUsingAlias(RcpEventRequestsPeer::ID, $eventRequestProposalFreeDay->getEventRequestId(), $comparison);
        } elseif ($eventRequestProposalFreeDay instanceof PropelObjectCollection) {
            return $this
                ->useEventRequestProposalFreeDayQuery()
                ->filterByPrimaryKeys($eventRequestProposalFreeDay->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByEventRequestProposalFreeDay() only accepts arguments of type RcpEventRequestProposalFreeDay or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the EventRequestProposalFreeDay relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function joinEventRequestProposalFreeDay($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('EventRequestProposalFreeDay');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'EventRequestProposalFreeDay');
        }

        return $this;
    }

    /**
     * Use the EventRequestProposalFreeDay relation EventRequestProposalFreeDay object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   RcpEventRequestProposalFreeDayQuery A secondary query class using the current class as primary query
     */
    public function useEventRequestProposalFreeDayQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinEventRequestProposalFreeDay($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'EventRequestProposalFreeDay', 'RcpEventRequestProposalFreeDayQuery');
    }

    /**
     * Filter the query by a related RcpViewCalendarEvents object
     *
     * @param   RcpViewCalendarEvents|PropelObjectCollection $viewCalendarEvents  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   RcpEventRequestsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByViewCalendarEvents($viewCalendarEvents, $comparison = null)
    {
        if ($viewCalendarEvents instanceof RcpViewCalendarEvents) {
            return $this
                ->addUsingAlias(RcpEventRequestsPeer::ID, $viewCalendarEvents->getEventRequestId(), $comparison);
        } elseif ($viewCalendarEvents instanceof PropelObjectCollection) {
            return $this
                ->useViewCalendarEventsQuery()
                ->filterByPrimaryKeys($viewCalendarEvents->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByViewCalendarEvents() only accepts arguments of type RcpViewCalendarEvents or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the ViewCalendarEvents relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function joinViewCalendarEvents($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('ViewCalendarEvents');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'ViewCalendarEvents');
        }

        return $this;
    }

    /**
     * Use the ViewCalendarEvents relation ViewCalendarEvents object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   RcpViewCalendarEventsQuery A secondary query class using the current class as primary query
     */
    public function useViewCalendarEventsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinViewCalendarEvents($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'ViewCalendarEvents', 'RcpViewCalendarEventsQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   RcpEventRequests $eventRequests Object to remove from the list of results
     *
     * @return RcpEventRequestsQuery The current query, for fluid interface
     */
    public function prune($eventRequests = null)
    {
        if ($eventRequests) {
            $this->addUsingAlias(RcpEventRequestsPeer::ID, $eventRequests->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
